<%--
  Created by IntelliJ IDEA.
  User: 狗蛋
  Date: 2019/10/31
  Time: 17:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>上传</title>
    <script>
      //判断是否填写上传人 和 选择好文件
      function check() {
        var name=document.getElementById("name").value;
        var file=document.getElementById("file").value;
        if (name==""){
          alert("请填写名称")
          return false;
        }
        if (file.length==0||file==""){
          alert("请选择上传文件")
          return false;
        }
        return true;
      }
    </script>
  </head>
  <body>

<%--
  web上传
  <form action="${pageContext.request.contextPath}/user/filenb" method="post" enctype="multipart/form-data" onsubmit="check()">
      上传人: <input id="name" type="text" name="name">
    选择文件: <input id="file" type="file" name="FileUpload" multiple="multiple">
            <input type="submit" value="提交">

  </form>
--%>

   SpringMVC上传
  <form action="${pageContext.request.contextPath}/user/fileMVC" method="post" enctype="multipart/form-data" onsubmit="check()">
    上传人: <input id="name1" type="text" name="name">
    选择文件: <input id="file1" type="file" name="FileUpload" multiple="multiple">
    <input type="submit" value="提交">
  </form>

  <a href="${pageContext.request.contextPath}/user/download?filename=mybatis.bmp">
    文件下载
  </a>
  </body>
</html>
